package com.lb.jwitter.action;


import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import java.util.Map; 
import org.springframework.test.context.ContextConfiguration; 
import com.lb.jwitter.service.TblQuyenChiTietService; 
import com.lb.jwitter.service.TblTaiKhoan; 
import com.opensymphony.xwork2.ActionContext; 
import com.lb.jwitter.util.ApplicationContextProvider; 
import java.util.ArrayList;
import com.lb.jwitter.service.ConditionReport; 
 import com.opensymphony.xwork2.Action; 
import com.lb.jwitter.service.TblQLDTTXAHocKyTrongNam;
import com.lb.jwitter.service.TblQLDTTXAHocKyTrongNamService;
import com.lb.jwitter.service.TblQLDTTXANamHoc;
import com.lb.jwitter.service.TblQLDTTXANamHocService;

import com.lb.jwitter.service.TblQLDTTXALopMonHocDuKien;
import com.lb.jwitter.service.TblQLDTTXALopMonHocDuKienService;

import com.lb.jwitter.service.TblQLDTTXAMonHoc;
import com.lb.jwitter.service.TblQLDTTXAMonHocService;

import com.lb.jwitter.service.TblQLDTTXAGiaoVien;
import com.lb.jwitter.service.TblQLDTTXAGiaoVienService;

 /** 
 * @author QUOCVIET  
 * 
 */ 


@ContextConfiguration(locations="classpath:beans.xml") 
public class TblQLDTTXAHocKyTrongNamEditFormAction{
    private int id; 
    public void setId(int id) {
       this.id = id;
 }

    public int getId() {
       return id;
 }

    private TblQLDTTXAHocKyTrongNam tblQLDTTXAHocKyTrongNam; 
    public TblQLDTTXAHocKyTrongNam getTblQLDTTXAHocKyTrongNam() { 
        return tblQLDTTXAHocKyTrongNam; 
    } 
    private TblQLDTTXAHocKyTrongNamService tblQLDTTXAHocKyTrongNamService; 

    private List<TblQLDTTXANamHoc> tblQLDTTXANamHocs; 
    public List<TblQLDTTXANamHoc>  getTblQLDTTXANamHocs(){ 
              return tblQLDTTXANamHocs; 
     } 

    private TblQLDTTXANamHocService tblQLDTTXANamHocService; 

    private List<TblQLDTTXALopMonHocDuKien> tblQLDTTXALopMonHocDuKiens; 
    public List<TblQLDTTXALopMonHocDuKien>  getTblQLDTTXALopMonHocDuKiens(){ 
              return tblQLDTTXALopMonHocDuKiens; 
     } 

    private TblQLDTTXALopMonHocDuKienService tblQLDTTXALopMonHocDuKienService; 

    private List<TblQLDTTXAMonHoc> tblQLDTTXAMonHocs; 
    public List<TblQLDTTXAMonHoc>  getTblQLDTTXAMonHocs(){ 
              return tblQLDTTXAMonHocs; 
     } 

    private TblQLDTTXAMonHocService tblQLDTTXAMonHocService; 

    private List<TblQLDTTXAGiaoVien> tblQLDTTXAGiaoViens; 
    public List<TblQLDTTXAGiaoVien>  getTblQLDTTXAGiaoViens(){ 
              return tblQLDTTXAGiaoViens; 
     } 

    private TblQLDTTXAGiaoVienService tblQLDTTXAGiaoVienService; 

  private TblTaiKhoan taiKhoanDangNhap; 
 public TblTaiKhoan getTaiKhoanDangNhap() { 
     return taiKhoanDangNhap; 
 } 
 public void setTaiKhoanDangNhap(TblTaiKhoan taiKhoanDangNhap) { 
     this.taiKhoanDangNhap = taiKhoanDangNhap; 
 } 
 private TblQuyenChiTietService tblQuyenChiTietService;
	 @Autowired // Injected by Spring 
     ApplicationContextProvider contextProvider; 
    public String execute() throws Exception 
   { 
       try{ 
     Map session = ActionContext.getContext().getSession();
     taiKhoanDangNhap =  (TblTaiKhoan) session.get("taiKhoan");
     if( taiKhoanDangNhap == null) return "noprivilege";
    ApplicationContext context = ApplicationContextProvider.getApplicationContext(); 
    tblQuyenChiTietService = (TblQuyenChiTietService) context.getBean("tbl_Quyen_ChiTietClient"); 
    if(!tblQuyenChiTietService.checkRight(taiKhoanDangNhap.getMaNhomQuyen().getId(), "tbl_QLDTTXA_HocKyTrongNam", "sua")){ 
        return "noprivilege"; 
    }        
    tblQLDTTXAHocKyTrongNamService = (TblQLDTTXAHocKyTrongNamService) context.getBean("tbl_QLDTTXA_HocKyTrongNamClient"); 
        tblQLDTTXANamHocService = (TblQLDTTXANamHocService) context.getBean("tbl_QLDTTXA_NamHocClient"); 

        tblQLDTTXALopMonHocDuKienService = (TblQLDTTXALopMonHocDuKienService) context.getBean("tbl_QLDTTXA_LopMonHoc_DuKienClient"); 

        tblQLDTTXAMonHocService = (TblQLDTTXAMonHocService) context.getBean("tbl_QLDTTXA_MonHocClient"); 

        tblQLDTTXAGiaoVienService = (TblQLDTTXAGiaoVienService) context.getBean("tbl_QLDTTXA_GiaoVienClient"); 

        tblQLDTTXAHocKyTrongNam = tblQLDTTXAHocKyTrongNamService.gettblQLDTTXAHocKyTrongNam(new Long(id)); 
        tblQLDTTXANamHocs = tblQLDTTXANamHocService.findAlltblQLDTTXANamHoc(0, 0);

        List<ConditionReport> cons = new ArrayList<ConditionReport>(); 
        if(true){
        ConditionReport con = new ConditionReport(); 
  	    con.setCol("ten");
  	    con.setValue1("asc");
  	    con.setOperator("order");
  	    cons.add(con);
        }
        
        tblQLDTTXAMonHocs =       tblQLDTTXAMonHocService.findtblQLDTTXAMonHocByCondition(cons, 0, 0);
   //List<ConditionReport> cons = new ArrayList<ConditionReport>();
        cons.clear();
   if (id != 0) 
   { 
       ConditionReport con = new ConditionReport(); 
       con.setCol("hocKyId.id"); 
       con.setValue1(new Long(id)); 
       con.setOperator("eq"); 
       cons.add(con); 
   } 
   tblQLDTTXALopMonHocDuKiens = tblQLDTTXALopMonHocDuKienService.findtblQLDTTXALopMonHocDuKienByCondition(cons, 0, 0); 
      tblQLDTTXAGiaoViens =       tblQLDTTXAGiaoVienService.findAlltblQLDTTXAGiaoVien(0, 0); 
        return Action.SUCCESS; 
      } 
      catch(Exception e){ 
      System.out.println("Loi EditForm tbl_QLDTTXA_HocKyTrongNam Action"); 
     e.printStackTrace(); 
    return Action.ERROR; 
 } 
 } 
 } 
 
